package com.bjx.gateway.config;

import cn.dev33.satoken.exception.SaTokenException;
import com.bjx.common.core.constant.FrameConst;
import com.bjx.common.core.domain.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @desc: 统一异常处理
 * @author: liushuai
 * @date: 2022/7/7 17:34
 */
@ControllerAdvice
public class SaExceptionHandler {



    /**
     * 权限异常
     * @param e 
     * @return: com.bjx.common.core.domain.R
     * @Author: liushuai
     * @Date: 2022/7/7 17:28
     */
    @ExceptionHandler(SaTokenException.class)
    public R handlerSaTokenException(SaTokenException e) {

        // 根据不同异常细分状态码返回不同的提示
       System.out.println(e.getCode());
        return R.fail(null, FrameConst.LOSE_PAST,"登录过期");
    }

}
